import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();

        List<Integer> list = new ArrayList<>();

        while (n > 0) {
            n--;
            int x = scanner.nextInt();
            int len = scanner.nextInt();
            switch(x) {
                case 1 :
                    if (list.contains(len)) {
                        System.out.println("Already Exist");
                    } else {
                        list.add(len);
                        Collections.sort(list);
                    }
                    break;
                case 2 :
                    int size = list.size();
                    if (size == 0) {
                        System.out.println("Empty");
                    } else if (!list.contains(len)){
                        int little = -1;
                        int large = -1;
                        for (int i : list) {
                            if (i < len) {
                                little = i;
                            } else {
                                large = i;
                                break;
                            }
                        }
                        if (little == -1) {
                            System.out.println(large);
                            list.remove(Integer.valueOf(large)); //根据元素删除，而不是下标
                        } else if (large == -1) {
                            System.out.println(little);
                            list.remove(Integer.valueOf(little));
                        } else if (little == large){
                            System.out.println(little);
                            list.remove(Integer.valueOf(little));
                        } else {
                            int i = large - len > len - little ? little : large;
                            System.out.println(i);
                            list.remove(Integer.valueOf(i));
                        }
                    } else {
                        System.out.println(len);
                        list.remove(Integer.valueOf(len));
                    }
                    break;
            }

        }


        scanner.close();
    }
}
